package com.ean.backpack.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ean.backpack.domain.Chainlist;
import com.ean.backpack.repository.ChainlistRepository;
import com.ean.backpack.service.ChainlistService;

@Service
@Transactional
public class ChainlistServiceImpl implements ChainlistService {

	@Autowired
	ChainlistRepository chainlistRepository;

	public long countAllChainlists() {
		return chainlistRepository.count();
	}

	public void deleteChainlist(Chainlist chainlist) {
		chainlistRepository.delete(chainlist);
	}

	public Chainlist findChainlist(Integer id) {
		return chainlistRepository.findOne(id);
	}

	public List<Chainlist> findAllChainlists() {
		return chainlistRepository.findAll();
	}

	public List<Chainlist> findChainlistEntries(int firstResult, int maxResults) {
		return chainlistRepository.findAll(
				new org.springframework.data.domain.PageRequest(firstResult
						/ maxResults, maxResults)).getContent();
	}

	public void saveChainlist(Chainlist chainlist) {
		chainlistRepository.save(chainlist);
	}

	public Chainlist updateChainlist(Chainlist chainlist) {
		return chainlistRepository.save(chainlist);
	}
}
